﻿Imports BUS
Imports DTO
Public Class frmTHEMSANPHAM


    Dim mhbus As MatHangBUS = New MatHangBUS

    Private Sub btn_them_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_them.Click
        themsp()
        LoadDsMatHang()
        MessageBox.Show("Đã Thêm Thành Công!")
    End Sub


    Private Sub themsp()

        Dim spdto As New MatHangDTO()
        spdto.TenSP = txt_tenhang.Text
        spdto.NgaySanXuat = dtp_ngasx.Value
        spdto.MaLoai = cbb_maloia.SelectedValue
        spdto.GiaBan = txt_giaban.Text
        MatHangBUS.ThemSP(spdto)
    End Sub
     

    Private Sub frmTHEMSANPHAM_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadDsMatHang()
        LoadMaloai()
    End Sub

    Private Sub LoadDsMatHang()
        Dim dt As DataTable = New DataTable
        dt = mhbus.LoadMH()
        dgv_ThemSP.DataSource = dt
    End Sub

    Private Sub LoadMaloai()
        cbb_maloia.DataSource = LoaiBUS.LayTatCaTT()
        cbb_maloia.DisplayMember = "TenLoai"
        cbb_maloia.ValueMember = "MaLoai"

    End Sub

    Private Sub btn_thoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_thoat.Click
        Me.Close()
    End Sub

    Private Sub cbb_maloia_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbb_maloia.SelectedIndexChanged

    End Sub
End Class